package com.ledim.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.ledim.bean.LedimChoiceCardBean;
import com.facebook.drawee.view.SimpleDraweeView;
import com.letv.android.young.client.R;
import com.ledim.utils.DensityUtil;
import java.util.List;

/**
 * Created by ccx on 16/8/4.
 */
public class TagsCardAdapter extends CardBaseAdapter

{

    public TagsCardAdapter(Context c, List dataList, String groupId) {
        super(c, dataList, groupId);
    }

    public TagsCardAdapter(Context c, String groupId) {
        super(c, groupId);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        CardTagsViewHolder holder;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.item_label_listview, null);
            holder = new CardTagsViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (CardTagsViewHolder) convertView.getTag();
        }

        if (position == 0) {
            ((LinearLayout.LayoutParams) holder.ll_tag_item.getLayoutParams()).setMargins(0, 0, 0, 0);
        } else {
            ((LinearLayout.LayoutParams) holder.ll_tag_item.getLayoutParams()).setMargins(0, DensityUtil
                    .dip2px(context, 8), 0, 0);
        }
        LedimChoiceCardBean mCard = getItem(position);
        //设置播放次数
        if (holder.tv_movie_counts != null && mCard.simple_album != null &&
                mCard.simple_album.play_count != null) {
            holder.tv_movie_counts.setText(mCard.simple_album.play_count);
        }
        initCommonView(convertView, holder, position);
        return convertView;
    }

    public static class CardTagsViewHolder extends CardBaseAdapter.CardBaseViewHolder {

        //电影播放次数
        public TextView tv_movie_counts;
        public LinearLayout ll_tag_item;

        public CardTagsViewHolder(View view) {
            super(view);
        }

        @Override
        public void initHoldView(View view) {
            mPhoto = (SimpleDraweeView) view.findViewById(R.id.sdv_movie_image);
            mTitle = (TextView) view.findViewById(R.id.tv_movie_name);
            mRating = (TextView) view.findViewById(R.id.tv_score);
            mEpisodesCount = (TextView) view.findViewById(R.id.tv_updata_episodes);
            tv_movie_counts = (TextView) view.findViewById(R.id.tv_movie_counts);
            ll_tag_item = (LinearLayout) view.findViewById(R.id.ll_tag_item);

        }
    }

}
